package com.chixing.controller;


import com.chixing.entity.Dish;
import com.chixing.entity.Mycoupon;
import com.chixing.service.IMycouponService;
import com.chixing.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

import java.time.LocalDateTime;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author smith
 * @since 2025-05-21
 */
@RestController
@RequestMapping("/mycoupon")
public class MycouponController {
    @Autowired
    private IMycouponService mycouponService;

    @GetMapping
    public Result getAll(){
        Result result=mycouponService.getAll();
        return result;
    }


    @GetMapping("status/{status}")
    public Result getAllmycoupons(@PathVariable("status") Integer status){
        Result result =mycouponService.getMycouponByCustomerId(1,status);
        return result;
    }





    @PostMapping
    public Result save(@RequestBody Mycoupon mycoupon){
        mycoupon.setStatus(0);
        mycoupon.setCustId(1);

        return mycouponService.save(mycoupon);
    }



}
